Skip to content

Fix Spanner cursor handling of mid-stream errors - #19089

Open
rahulcomet wants to merge 1 commit into
googleapis:mainfrom
rahulcomet:fix/spanner-19079-fetch-errors
Open

rahulcomet wants to merge 1 commit into
googleapis:mainfrom
rahulcomet:fix/spanner-19079-fetch-errors

Conversation

@rahulcomet

Copy link
Copy Markdown

Summary

Raise mid-stream fetch errors so callers can detect incomplete Spanner query results. After a successful read-write transaction retry, resume from the replayed cursor without repeating rows already returned.

Fixes #19079

Testing

The new regression tests failed before the fix and passed afterward. All 271 DB-API unit tests and 112 mock-server tests passed. The broader unit suite had failures that also reproduced with the original cursor code.

@rahulcomet
rahulcomet requested a review from a team as a code owner November 15, 2026 08:28
@google-cla

google-cla Bot commented Nov 15, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the _fetch method in the Spanner DB-API cursor to handle aborted transactions by retrying the transaction and restoring the cursor state from the replayed cursor. It also ensures exceptions are explicitly re-raised during fetch operations. The unit tests have been updated and expanded to verify these behaviors, including testing cursor replay and exception propagation. There are no review comments, so I have no feedback to provide.

@rahulcomet
rahulcomet force-pushed the fix/spanner-19079-fetch-errors branch from 3ca8721 to fed518a Compare November 15, 2026 08:33
@olavloite olavloite added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 17, 2026
@olavloite

Copy link
Copy Markdown
Contributor

This PR does correctly identify a problem with how dbapi cursors handle errors, but it is not complete. I will create separate PRs to fix these issues.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Indicates a pull request not ready for merge, due to either quality or timing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(google-cloud-spanner) DB-API Cursor fetchall/fetchmany/fetchone silently return partial results when the result stream fails mid-read

2 participants